package com.eight.group.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.eight.group.entity.QueryPageBean;
import com.eight.group.entity.Result;
import com.eight.group.mapper.MemberManagerMapper;
import com.eight.group.pojo.User;
import com.xqx.eight.group.service.MemberManagerService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
import java.util.Map;

@Service
public class MemberManagerServiceimpl implements MemberManagerService {
    @Autowired
    private MemberManagerMapper managerMapper;

    @Override
    public List<Map<String, Object>> findPage(QueryPageBean bean) {
        System.out.println(bean);
        // String str = bean.getQueryString();
        String str = bean.getQueryString() == null || bean.getQueryString() == "" ? null : "%" + bean.getQueryString() + "%";
        System.out.println(str);
        List<Map<String, Object>> page = managerMapper.findPage(str);
        return page;
    }

    //删除
    @Override
    public Result delete(int id) {
        Integer info = managerMapper.findOrderByMemberId(id);
        if (info >= 1) {
            return new Result(false, "此表和订单信息关联！不能删除");
        } else {
            managerMapper.delete(id);
        }
        return new Result(true, "删除成功");
    }

    @Override
    public void add(Map<String, Object> map) {
        managerMapper.add(map);
    }

    @Override
    public Map<String, Object> findById(int id) {
        Map<String, Object> list = managerMapper.findById(id);
        System.out.println("糊了" + list);
        return list;
    }

    @Override
    public void edit(Map<String, Object> map) {
        managerMapper.edit(map);
    }

    @Override
    public List<Map<String, Object>> findExcel() {
        List<Map<String, Object>> excel = managerMapper.findExcel();
        return excel;
    }


    /**
     * 查询健康管理师列表
     *
     * @return
     */
    @Override
    public List<User> findAllHealthManager() {
        return managerMapper.findAllHealthManager();
    }
}
